<?php include load_tpl('header');?>
<p id="breadcrumbs">
    <a href="/">首页</a> <b>»</b> 
    <span>品牌列表</span>
</p>

<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('./images/shipping.png');">品牌列表</h1>
    <div class="buttons"><a onclick="location='index.php?mod=brand&act=add'" class="button"><span>添加</span></a><a id="dellink" class="button"><span>删除</span></a></div>
  </div>
  <div class="content">
    <form action="" method="post" enctype="multipart/form-data" id="form">
      <table class="list">
        <thead>
          <tr>
            <th width="1" style="text-align: center;"><input type="checkbox"/></th>
            <th class="left">品牌名称
              </th>
            <th class="right">排序权重
              </th>
            <th class="right">操作</th>
          </tr>
        </thead>
        <tbody>
		<?php if(isset($brand_list))foreach($brand_list as $brand){?>
            <tr>
            <td style="text-align: center;"><input type="checkbox" name="bid" value="<?php if(isset($brand['manufacturer_id']))echo $brand['manufacturer_id'];?>" />
            </td>
            <td class="left"><?php if(isset($brand['name']))echo $brand['name'];?></td>
            <td class="right"><?php if(isset($brand['sort_order']))echo $brand['sort_order'];?></td>
            <td class="right"><a class="button" href="index.php?mod=brand&act=edit&brand_id=<?php if(isset($brand['manufacturer_id']))echo $brand['manufacturer_id'];?>"><span>编辑</span></a>
            </td>
          </tr>
		  <?php } ?>
        </tbody>
      </table>
    </form>
</div>

<?php include load_tpl('footer');?>
<script type="text/javascript"> 
var arr = [];
$(document).ready(function() {
	$(".list thead tr th:first input:checkbox").click(function() {
		var checkedStatus = this.checked;
		$(".list tbody tr td:first-child input:checkbox").each(function() {
			this.checked = checkedStatus;
			if(checkedStatus){
				arr.push(this.value);
			}else{
				arr.pop(this.value);
			}
		});
	});
	$(".list tbody tr td:first-child input:checkbox").click(function() {
		if(this.checked){
			arr.push(this.value);
		}else{
			arr.pop(this.value);
		}
	});
	$("#dellink").click(function(){
		if(arr.length == 0){
			alert("请先选择!");
			return ;
		}
		window.location.href = "index.php?mod=brand&act=del&bid="+arr.join(",");
	});
});
</script>